package com.jm.day24.d_demo2.dao;

import com.jm.day24.utils.JdbcUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.SQLException;

public class AccountDao {


    public void out(String out, Double money) throws SQLException {
        // 创建一个QueryRunner
        QueryRunner runner = new QueryRunner(JdbcUtils.getDataSource());
        // 执行sql语句，扣钱
        runner.update("update account set money = money - ? where username = ?", money, out);
    }


    public void in(String in, Double money) throws SQLException {
        // 创建一个QueryRunner
        QueryRunner runner = new QueryRunner(JdbcUtils.getDataSource());
        // 执行sql语句，扣钱
        runner.update("update account set money = money + ? where username = ?", money, in);
    }
}

